In [1]:
import itertools
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.ticker import NullFormatter
import pandas as pd
import numpy as np
from sklearn.cluster import KMeans
In [2]:
df = pd.read_csv('../../preprocessing/apartments_preprocessed.csv')
In [3]:
df.head()
Out[3]:
| title | bathrooms | bedrooms | price | square_meters | cityname | state | latitude | longitude | source | luxury | |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | Studio apartment 2nd St NE, Uhland Terrace NE,... | 1.0 | 0.0 | 790 | 9.393 | Washington | DC | 38.9057 | -76.9861 | RentLingo | 0 |
| 1 | Studio apartment 814 Schutte Road | 1.0 | 1.0 | 425 | 9.858 | Evansville | IN | 37.9680 | -87.6621 | RentLingo | 0 |
| 2 | Studio apartment N Scott St, 14th St N, Arling... | 1.0 | 0.0 | 1390 | 9.951 | Arlington | VA | 38.8910 | -77.0816 | RentLingo | 0 |
| 3 | Studio apartment 1717 12th Ave | 1.0 | 0.0 | 925 | 10.788 | Seattle | WA | 47.6160 | -122.3275 | RentLingo | 0 |
| 4 | Studio apartment Washington Blvd, N Cleveland ... | 1.0 | 0.0 | 880 | 11.625 | Arlington | VA | 38.8738 | -77.1055 | RentLingo | 0 |
In [4]:
from geopy.geocoders import Nominatim
address = 'United States'
geolocator = Nominatim(user_agent="to_explorer")
location = geolocator.geocode(address)
latitude1 = location.latitude
longitude1 = location.longitude
print('The geograpical coordinate of USA are {}, {}.'.format(latitude1, longitude1))
The geograpical coordinate of USA are 39.7837304, -100.445882.
In [5]:
import folium
# create map of USA using latitude and longitude values
map_usa = folium.Map(location=[latitude1, longitude1], zoom_start=4)
# add markers to map
for lat, lng, propname in zip(df['latitude'], df['longitude'], df['title']):
label = '{}'.format(propname)
label = folium.Popup(label, parse_html=True)
folium.CircleMarker(
[lat, lng],
radius=5,
popup=label,
color='red',
fill=True,
fill_color='#FF5733',
fill_opacity=0.7,
parse_html=False).add_to(map_usa)
map_usa
Out[5]:
Make this Notebook Trusted to load map: File -> Trust Notebook